a = input()
sp = []
m = 0
for i in range(len(a)):
    if a[i] == "(" or a[i] == "{" or a[i] == "[" or a[i] == "<":
        sp.append(a[i])
    else:
        if len(sp) == 0:
            print("False")
            break
        else:
            last = sp.pop()
            if not (last == "[" and a[i] == "]" or
                    last == "{" and a[i] == "}" or 
                    last == "(" and a[i] == ")" or
                    last == "<" and a[i] == ">"):
                print("False")
                m = 1
                break
if len(sp) == 0 and m == 0:
    print("True")
elif len(sp) != 0 and m != 1:
    print("False")
